<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>消息列表</title>
    <style>
        .dataTB {
            width: 85%;
            border: 1px solid #ccc;
            line-height: 30px;
        }

        .dataTB_Individual {
            margin: 5% auto;
            font-size: 12px;
            height: 30px;
            text-align: center;
        }

        .table_attach th, .table_attach td {
            border: 1px solid #dbdee1;
            color: #202020;
            font-size: 12px;
            font-weight: normal;
            height: 23px;
            line-height: 23px;
            text-align: center;
        }
    </style>
</head>
<body>

<table class="dataTB dataTB_Individual">
    <thead>
    <tr class="titleTR" style="background-color: #53a4ea;display: table-row;
    vertical-align: inherit;
    border-color: inherit;border-collapse: collapse;">
        <td class="titleTD">节点名称</td>
        <td class="titleTD"> 电子邮件模版</td>
        <td class="titleTD">短信模板</td>
        <td class="titleTD">站内信模版</td>
        <td class="titleTD">电子邮件状态</td>
        <td class="titleTD">短信状态</td>
        <td class="titleTD">站内信状态</td>
        <td class="titleTD">配置启用状态</td>
        <td class="titleTD"> 操作</td>
    </tr>
    </thead>
    <tbody>
    <tr class="table_attach">
        <td>${mes.id}</td>
        <td><a href="javascript:void(0);"
               onclick="showEamilTemplate(this)">${mes.emailTemplate}</a></td>
        <td><a href="javascript:void(0);"
               onclick="showEamilTemplate(this)">${mes.msgTemplate}</a></td>
        <td><a href="javascript:void(0);"
               onclick="showEamilTemplate(this)">${mes.smsTemplate}</a></td>
        <td><select name="emailStatus" value="${mes.emailStatus}">
            <option value="1">启用</option>
            <option value="0">未启用</option>
        </select></td>
        <td><select name="smsStatus" value="${mes.smsStatus}">
            <option value="1">启用</option>
            <option value="0">未启用</option>
        </select></td>
        <td><select name="msgStatus" value="${mes.msgStatus}">
            <option value="1">启用</option>
            <option value="0">未启用</option>
        </select></td>
        <td><select name="status" value="${mes.status}">
            <option value="1">启用</option>
            <option value="0">未启用</option>
        </select></td>
        <td><a href="javascript:void(0);" onclick="updateMessage()">保存</a></td>
    </tr>
    </tbody>
</table>
<script type="text/javascript"
        src="<s:url value="/js/jquery/combobox/jquery.min-1.10.2.js"/>"></script>
<script type="text/javascript">
    function updateMessage() {
        $.ajax({
                   url: "/message/msg-updateMsgConfig",
                   data: {
                       id: "${mes.id}",
                       status: $("[name=status]").val(),
                       msgStatus: $("[name=msgStatus]").val(),
                       smsStatus: $("[name=smsStatus]").val(),
                       emailStatus: $("[name=emailStatus]").val()
                   },
                   success: function (data) {
                       data = eval("(" + data + ")");
                       if (data.state == 1) {
                           alert(data.msg);
                           location.href = "/message/msg-msgMain";
                       }
                   }
               });
    }

    var isShow = false;
    function showEamilTemplate(e) {
        var parentRow = $(e).parent().parent();
        if (isShow) {   //
            parentRow.next().remove();
            isShow = false;
        } else {
            parentRow.after('<tr  class="table_attach"><td colspan="9"><div>After</div></td></tr>');
            isShow = true;
        }

    }
</script>
</body>
</html>
